
<!DOCTYPE HTML>
<html lang="" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Reactor Gateways · GitBook</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        
        
        
    
    <link rel="stylesheet" href="../../../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-search/search.css">
                
            
                
                <link rel="stylesheet" href="../../../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
        

    

    
        
        <link rel="stylesheet" href="../../../styles/website.css">
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../../../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../../spring-cloud.html" />
    
    
    <link rel="prev" href="../reactor.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="Type to search" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    

    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../../../">
            
                <a href="../../../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../../../architecture-overview/">
            
                <a href="../../../architecture-overview/">
            
                    
                    Architecture Overview
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../../../architecture-overview/ddd-cqrs-concepts.html">
            
                <a href="../../../architecture-overview/ddd-cqrs-concepts.html">
            
                    
                    DDD & CQRS Concepts
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.2" data-path="../../../architecture-overview/event-sourcing.html">
            
                <a href="../../../architecture-overview/event-sourcing.html">
            
                    
                    Event Sourcing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2.3" data-path="../../../architecture-overview/event-driven-microservices.html">
            
                <a href="../../../architecture-overview/event-driven-microservices.html">
            
                    
                    Event-Driven Microservices
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../../../axon-server-introduction.html">
            
                <a href="../../../axon-server-introduction.html">
            
                    
                    Axon Server
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../../../release-notes/">
            
                <a href="../../../release-notes/">
            
                    
                    Release Notes
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../../../release-notes/rn-axon-framework/">
            
                <a href="../../../release-notes/rn-axon-framework/">
            
                    
                    Axon Framework
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1.1" data-path="../../../release-notes/rn-axon-framework/rn-af-major-releases.html">
            
                <a href="../../../release-notes/rn-axon-framework/rn-af-major-releases.html">
            
                    
                    Major Releases
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.1.2" data-path="../../../release-notes/rn-axon-framework/rn-af-minor-releases.html">
            
                <a href="../../../release-notes/rn-axon-framework/rn-af-minor-releases.html">
            
                    
                    Minor Releases
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../../../release-notes/rn-axon-server/">
            
                <a href="../../../release-notes/rn-axon-server/">
            
                    
                    Axon Server
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.2.1" data-path="../../../release-notes/rn-axon-server/rn-as-major-releases.html">
            
                <a href="../../../release-notes/rn-axon-server/rn-as-major-releases.html">
            
                    
                    Major Releases
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.2" data-path="../../../release-notes/rn-axon-server/rn-asse-minor-releases.html">
            
                <a href="../../../release-notes/rn-axon-server/rn-asse-minor-releases.html">
            
                    
                    Minor Releases Standard Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2.3" data-path="../../../release-notes/rn-axon-server/rn-as-minor-releases.html">
            
                <a href="../../../release-notes/rn-axon-server/rn-as-minor-releases.html">
            
                    
                    Minor Releases Enterprise Edition
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../../../release-notes/axon-framework-extensions.html">
            
                <a href="../../../release-notes/axon-framework-extensions.html">
            
                    
                    Axon Framework Extensions
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">Getting Started</li>
        
        
    
        <li class="chapter " data-level="2.1" data-path="../../../getting-started/quick-start.html">
            
                <a href="../../../getting-started/quick-start.html">
            
                    
                    Quick Start
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Axon Framework</li>
        
        
    
        <li class="chapter " data-level="3.1" data-path="../../../axon-framework/introduction.html">
            
                <a href="../../../axon-framework/introduction.html">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="../../../axon-framework/messaging-concepts/">
            
                <a href="../../../axon-framework/messaging-concepts/">
            
                    
                    Messaging Concepts
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.2.1" data-path="../../../axon-framework/messaging-concepts/anatomy-message.html">
            
                <a href="../../../axon-framework/messaging-concepts/anatomy-message.html">
            
                    
                    Anatomy of a Message
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.2" data-path="../../../axon-framework/messaging-concepts/message-correlation.html">
            
                <a href="../../../axon-framework/messaging-concepts/message-correlation.html">
            
                    
                    Message Correlation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.3" data-path="../../../axon-framework/messaging-concepts/message-intercepting.html">
            
                <a href="../../../axon-framework/messaging-concepts/message-intercepting.html">
            
                    
                    Message Intercepting
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.4" data-path="../../../axon-framework/messaging-concepts/supported-parameters-annotated-handlers.html">
            
                <a href="../../../axon-framework/messaging-concepts/supported-parameters-annotated-handlers.html">
            
                    
                    Supported Parameters for Annotated Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.5" data-path="../../../axon-framework/messaging-concepts/exception-handling.html">
            
                <a href="../../../axon-framework/messaging-concepts/exception-handling.html">
            
                    
                    Exception Handling
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.2.6" data-path="../../../axon-framework/messaging-concepts/unit-of-work.html">
            
                <a href="../../../axon-framework/messaging-concepts/unit-of-work.html">
            
                    
                    Unit of Work
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="../../../axon-framework/axon-framework-commands/">
            
                <a href="../../../axon-framework/axon-framework-commands/">
            
                    
                    Commands
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1" data-path="../../../axon-framework/axon-framework-commands/modeling/">
            
                <a href="../../../axon-framework/axon-framework-commands/modeling/">
            
                    
                    Modeling
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.3.1.1" data-path="../../../axon-framework/axon-framework-commands/modeling/aggregate.html">
            
                <a href="../../../axon-framework/axon-framework-commands/modeling/aggregate.html">
            
                    
                    Aggregate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.2" data-path="../../../axon-framework/axon-framework-commands/modeling/multi-entity-aggregates.html">
            
                <a href="../../../axon-framework/axon-framework-commands/modeling/multi-entity-aggregates.html">
            
                    
                    Multi-Entity Aggregates
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.3" data-path="../../../axon-framework/axon-framework-commands/modeling/state-stored-aggregates.html">
            
                <a href="../../../axon-framework/axon-framework-commands/modeling/state-stored-aggregates.html">
            
                    
                    State Stored Aggregates
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.4" data-path="../../../axon-framework/axon-framework-commands/modeling/aggregate-creation-from-another-aggregate.html">
            
                <a href="../../../axon-framework/axon-framework-commands/modeling/aggregate-creation-from-another-aggregate.html">
            
                    
                    Aggregate Creation from another Aggregate
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.5" data-path="../../../axon-framework/axon-framework-commands/modeling/aggregate-polymorphism.html">
            
                <a href="../../../axon-framework/axon-framework-commands/modeling/aggregate-polymorphism.html">
            
                    
                    Aggregate Polymorphism
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.1.6" data-path="../../../axon-framework/axon-framework-commands/modeling/conflict-resolution.html">
            
                <a href="../../../axon-framework/axon-framework-commands/modeling/conflict-resolution.html">
            
                    
                    Conflict Resolution
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.3.2" data-path="../../../axon-framework/axon-framework-commands/command-dispatchers.html">
            
                <a href="../../../axon-framework/axon-framework-commands/command-dispatchers.html">
            
                    
                    Command Dispatchers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.3" data-path="../../../axon-framework/axon-framework-commands/command-handlers.html">
            
                <a href="../../../axon-framework/axon-framework-commands/command-handlers.html">
            
                    
                    Command Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.4" data-path="../../../axon-framework/axon-framework-commands/infrastructure.html">
            
                <a href="../../../axon-framework/axon-framework-commands/infrastructure.html">
            
                    
                    Infrastructure
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.3.5" data-path="../../../axon-framework/axon-framework-commands/configuration.html">
            
                <a href="../../../axon-framework/axon-framework-commands/configuration.html">
            
                    
                    Configuration
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="../../../axon-framework/events/">
            
                <a href="../../../axon-framework/events/">
            
                    
                    Events
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.1" data-path="../../../axon-framework/events/event-dispatchers.html">
            
                <a href="../../../axon-framework/events/event-dispatchers.html">
            
                    
                    Event Dispatchers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.2" data-path="../../../axon-framework/events/event-handlers.html">
            
                <a href="../../../axon-framework/events/event-handlers.html">
            
                    
                    Event Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3" data-path="../../../axon-framework/events/event-processors/">
            
                <a href="../../../axon-framework/events/event-processors/">
            
                    
                    Event Processors
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.4.3.1" data-path="../../../axon-framework/events/event-processors/subscribing.html">
            
                <a href="../../../axon-framework/events/event-processors/subscribing.html">
            
                    
                    Subscribing Event Processors
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.3.2" data-path="../../../axon-framework/events/event-processors/streaming.html">
            
                <a href="../../../axon-framework/events/event-processors/streaming.html">
            
                    
                    Streaming Event Processors
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.4.4" data-path="../../../axon-framework/events/event-bus-and-event-store.html">
            
                <a href="../../../axon-framework/events/event-bus-and-event-store.html">
            
                    
                    Event Bus & Event Store
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.5" data-path="../../../axon-framework/events/event-versioning.html">
            
                <a href="../../../axon-framework/events/event-versioning.html">
            
                    
                    Event Versioning
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.4.6" data-path="../../../axon-framework/events/event-serialization.html">
            
                <a href="../../../axon-framework/events/event-serialization.html">
            
                    
                    Event Serialization
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="../../../axon-framework/queries/">
            
                <a href="../../../axon-framework/queries/">
            
                    
                    Queries
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.5.1" data-path="../../../axon-framework/queries/query-processing.html">
            
                <a href="../../../axon-framework/queries/query-processing.html">
            
                    
                    Query Processing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.2" data-path="../../../axon-framework/queries/query-dispatchers.html">
            
                <a href="../../../axon-framework/queries/query-dispatchers.html">
            
                    
                    Query Dispatchers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.3" data-path="../../../axon-framework/queries/query-handlers.html">
            
                <a href="../../../axon-framework/queries/query-handlers.html">
            
                    
                    Query Handlers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.4" data-path="../../../axon-framework/queries/implementations.html">
            
                <a href="../../../axon-framework/queries/implementations.html">
            
                    
                    Implementations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.5.5" data-path="../../../axon-framework/queries/configuration.html">
            
                <a href="../../../axon-framework/queries/configuration.html">
            
                    
                    Configuration
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="../../../axon-framework/sagas/">
            
                <a href="../../../axon-framework/sagas/">
            
                    
                    Sagas
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.6.1" data-path="../../../axon-framework/sagas/implementation.html">
            
                <a href="../../../axon-framework/sagas/implementation.html">
            
                    
                    Implementation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.2" data-path="../../../axon-framework/sagas/associations.html">
            
                <a href="../../../axon-framework/sagas/associations.html">
            
                    
                    Associations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.6.3" data-path="../../../axon-framework/sagas/infrastructure.html">
            
                <a href="../../../axon-framework/sagas/infrastructure.html">
            
                    
                    Infrastructure
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.7" data-path="../../../axon-framework/deadlines/">
            
                <a href="../../../axon-framework/deadlines/">
            
                    
                    Deadlines
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.7.1" data-path="../../../axon-framework/deadlines/deadline-managers.html">
            
                <a href="../../../axon-framework/deadlines/deadline-managers.html">
            
                    
                    Deadline Managers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.7.2" data-path="../../../axon-framework/deadlines/event-schedulers.html">
            
                <a href="../../../axon-framework/deadlines/event-schedulers.html">
            
                    
                    Event Schedulers
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.8" data-path="../../../axon-framework/testing/">
            
                <a href="../../../axon-framework/testing/">
            
                    
                    Testing
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.8.1" data-path="../../../axon-framework/testing/commands-events.html">
            
                <a href="../../../axon-framework/testing/commands-events.html">
            
                    
                    Commands / Events
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.8.2" data-path="../../../axon-framework/testing/sagas-1.html">
            
                <a href="../../../axon-framework/testing/sagas-1.html">
            
                    
                    Sagas
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.9" data-path="../../../axon-framework/tuning/">
            
                <a href="../../../axon-framework/tuning/">
            
                    
                    Tuning
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.9.1" data-path="../../../axon-framework/tuning/event-snapshots.html">
            
                <a href="../../../axon-framework/tuning/event-snapshots.html">
            
                    
                    Event Snapshots
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9.2" data-path="../../../axon-framework/tuning/event-processing.html">
            
                <a href="../../../axon-framework/tuning/event-processing.html">
            
                    
                    Event Processing
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.9.3" data-path="../../../axon-framework/tuning/command-processing.html">
            
                <a href="../../../axon-framework/tuning/command-processing.html">
            
                    
                    Command Processing
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3.10" data-path="../../../axon-framework/monitoring-and-metrics.html">
            
                <a href="../../../axon-framework/monitoring-and-metrics.html">
            
                    
                    Monitoring and Metrics
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.11" data-path="../../../axon-framework/spring-boot-integration.html">
            
                <a href="../../../axon-framework/spring-boot-integration.html">
            
                    
                    Spring Boot Integration
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="3.12" data-path="../../../axon-framework/modules.html">
            
                <a href="../../../axon-framework/modules.html">
            
                    
                    Modules
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Axon Server</li>
        
        
    
        <li class="chapter " data-level="4.1" data-path="../../../axon-server/introduction.html">
            
                <a href="../../../axon-server/introduction.html">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="../../../axon-server/installation/">
            
                <a href="../../../axon-server/installation/">
            
                    
                    Installation
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.1" data-path="../../../axon-server/installation/local-installation/">
            
                <a href="../../../axon-server/installation/local-installation/">
            
                    
                    Local Installation
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.1.1" data-path="../../../axon-server/installation/local-installation/axon-server-se.html">
            
                <a href="../../../axon-server/installation/local-installation/axon-server-se.html">
            
                    
                    Axon Server SE
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.1.2" data-path="../../../axon-server/installation/local-installation/axon-server-ee.html">
            
                <a href="../../../axon-server/installation/local-installation/axon-server-ee.html">
            
                    
                    Axon Server EE
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.2.2" data-path="../../../axon-server/installation/docker-k8s/">
            
                <a href="../../../axon-server/installation/docker-k8s/">
            
                    
                    Docker / K8s
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.2.2.1" data-path="../../../axon-server/installation/docker-k8s/axon-server-se.html">
            
                <a href="../../../axon-server/installation/docker-k8s/axon-server-se.html">
            
                    
                    Axon Server SE
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.2.2.2" data-path="../../../axon-server/installation/docker-k8s/axon-server-ee.html">
            
                <a href="../../../axon-server/installation/docker-k8s/axon-server-ee.html">
            
                    
                    Axon Server EE
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="../../../axon-server/administration/">
            
                <a href="../../../axon-server/administration/">
            
                    
                    Administration
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1" data-path="../../../axon-server/administration/admin-configuration/">
            
                <a href="../../../axon-server/administration/admin-configuration/">
            
                    
                    Configuration
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.1.1" data-path="../../../axon-server/administration/admin-configuration/configuration.html">
            
                <a href="../../../axon-server/administration/admin-configuration/configuration.html">
            
                    
                    System Properties
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.1.2" data-path="../../../axon-server/administration/admin-configuration/command-line-interface.html">
            
                <a href="../../../axon-server/administration/admin-configuration/command-line-interface.html">
            
                    
                    Command Line Interface
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.1.3" data-path="../../../axon-server/administration/admin-configuration/rest-api.html">
            
                <a href="../../../axon-server/administration/admin-configuration/rest-api.html">
            
                    
                    REST API
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3.2" data-path="../../../axon-server/administration/monitoring/">
            
                <a href="../../../axon-server/administration/monitoring/">
            
                    
                    Monitoring
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.3.2.1" data-path="../../../axon-server/administration/monitoring/actuator-endpoints.html">
            
                <a href="../../../axon-server/administration/monitoring/actuator-endpoints.html">
            
                    
                    Actuator Endpoints
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.2.2" data-path="../../../axon-server/administration/monitoring/grpc-metrics.html">
            
                <a href="../../../axon-server/administration/monitoring/grpc-metrics.html">
            
                    
                    gRPC Metrics
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.2.3" data-path="../../../axon-server/administration/monitoring/heartbeat-monitoring.html">
            
                <a href="../../../axon-server/administration/monitoring/heartbeat-monitoring.html">
            
                    
                    Heartbeat Monitoring
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.3.3" data-path="../../../axon-server/administration/clustering.html">
            
                <a href="../../../axon-server/administration/clustering.html">
            
                    
                    Clusters
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.4" data-path="../../../axon-server/administration/replication-groups.html">
            
                <a href="../../../axon-server/administration/replication-groups.html">
            
                    
                    Replication Groups
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.5" data-path="../../../axon-server/administration/multi-context.html">
            
                <a href="../../../axon-server/administration/multi-context.html">
            
                    
                    Multi-Context
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.6" data-path="../../../axon-server/administration/tagging.html">
            
                <a href="../../../axon-server/administration/tagging.html">
            
                    
                    Tagging
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.7" data-path="../../../axon-server/administration/backup-and-messaging-only-nodes.html">
            
                <a href="../../../axon-server/administration/backup-and-messaging-only-nodes.html">
            
                    
                    Backup and Messaging-only Nodes
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.8" data-path="../../../axon-server/administration/backups.html">
            
                <a href="../../../axon-server/administration/backups.html">
            
                    
                    Backups
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.9" data-path="../../../axon-server/administration/recovery.html">
            
                <a href="../../../axon-server/administration/recovery.html">
            
                    
                    Recovery
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.10" data-path="../../../axon-server/administration/plugins.html">
            
                <a href="../../../axon-server/administration/plugins.html">
            
                    
                    Plugins
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.3.11" data-path="../../../axon-server/administration/error-codes.html">
            
                <a href="../../../axon-server/administration/error-codes.html">
            
                    
                    Error Codes
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="../../../axon-server/security/">
            
                <a href="../../../axon-server/security/">
            
                    
                    Security
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="../../../axon-server/security/ssl.html">
            
                <a href="../../../axon-server/security/ssl.html">
            
                    
                    SSL
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="../../../axon-server/security/access-control.html">
            
                <a href="../../../axon-server/security/access-control.html">
            
                    
                    Access Control
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="../../../axon-server/security/access-control-se.html">
            
                <a href="../../../axon-server/security/access-control-se.html">
            
                    
                    Access Control - Standard Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.4" data-path="../../../axon-server/security/access-control-ee.html">
            
                <a href="../../../axon-server/security/access-control-ee.html">
            
                    
                    Access Control - Enterprise Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.5" data-path="../../../axon-server/security/access-control-clients.html">
            
                <a href="../../../axon-server/security/access-control-clients.html">
            
                    
                    Access Control - Client Applications
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.6" data-path="../../../axon-server/security/access-control-cli.html">
            
                <a href="../../../axon-server/security/access-control-cli.html">
            
                    
                    Access Control - CLI
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.7" data-path="../../../axon-server/security/access-control-api.html">
            
                <a href="../../../axon-server/security/access-control-api.html">
            
                    
                    Access Control - API
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.8" data-path="../../../axon-server/security/access-control-ldap.html">
            
                <a href="../../../axon-server/security/access-control-ldap.html">
            
                    
                    Access Control - LDAP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.4.9" data-path="../../../axon-server/security/access-control-oauth2.html">
            
                <a href="../../../axon-server/security/access-control-oauth2.html">
            
                    
                    Access Control - OAuth 2.0
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="../../../axon-server/performance/">
            
                <a href="../../../axon-server/performance/">
            
                    
                    Performance
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.5.1" data-path="../../../axon-server/performance/tuning-event-processing.html">
            
                <a href="../../../axon-server/performance/tuning-event-processing.html">
            
                    
                    Event Segments
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.5.2" data-path="../../../axon-server/performance/flow-control.html">
            
                <a href="../../../axon-server/performance/flow-control.html">
            
                    
                    Flow Control
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="../../../axon-server/migration/">
            
                <a href="../../../axon-server/migration/">
            
                    
                    Migration
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.6.1" data-path="../../../axon-server/migration/standard-to-enterprise-edition.html">
            
                <a href="../../../axon-server/migration/standard-to-enterprise-edition.html">
            
                    
                    Standard to Enterprise Edition
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="4.6.2" data-path="../../../axon-server/migration/non-axon-server-to-axon-server.html">
            
                <a href="../../../axon-server/migration/non-axon-server-to-axon-server.html">
            
                    
                    Non-Axon Server to Axon Server
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    
        
        <li class="header">Extensions</li>
        
        
    
        <li class="chapter " data-level="5.1" data-path="../../spring-amqp.html">
            
                <a href="../../spring-amqp.html">
            
                    
                    Spring AMQP
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="../../jgroups.html">
            
                <a href="../../jgroups.html">
            
                    
                    JGroups
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="../../kafka.html">
            
                <a href="../../kafka.html">
            
                    
                    Kafka
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="../../kotlin.html">
            
                <a href="../../kotlin.html">
            
                    
                    Kotlin
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="../../mongo.html">
            
                <a href="../../mongo.html">
            
                    
                    Mongo
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="../reactor.html">
            
                <a href="../reactor.html">
            
                    
                    Reactor
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="5.6.1" data-path="reactive-gateways.html">
            
                <a href="reactive-gateways.html">
            
                    
                    Reactor Gateways
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="../../spring-cloud.html">
            
                <a href="../../spring-cloud.html">
            
                    
                    Spring Cloud
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="../../tracing.html">
            
                <a href="../../tracing.html">
            
                    
                    Tracing
            
                </a>
            

            
        </li>
    

    
        
        <li class="header">Appendices</li>
        
        
    
        <li class="chapter " data-level="6.1" data-path="../../../appendices/rdbms-tuning.html">
            
                <a href="../../../appendices/rdbms-tuning.html">
            
                    
                    A. RDBMS Tuning
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="../../../appendices/message-handler-tuning/">
            
                <a href="../../../appendices/message-handler-tuning/">
            
                    
                    B. Message Handler Tuning
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.2.1" data-path="../../../appendices/message-handler-tuning/parameter-resolvers.html">
            
                <a href="../../../appendices/message-handler-tuning/parameter-resolvers.html">
            
                    
                    Parameter Resolvers
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.2.2" data-path="../../../appendices/message-handler-tuning/handler-enhancers.html">
            
                <a href="../../../appendices/message-handler-tuning/handler-enhancers.html">
            
                    
                    Handler Enhancers
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="../../../appendices/meta-annotations.html">
            
                <a href="../../../appendices/meta-annotations.html">
            
                    
                    C. Meta Annotations
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="../../../appendices/identifier-generation.html">
            
                <a href="../../../appendices/identifier-generation.html">
            
                    
                    D. Identifier Generation
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="../../../appendices/query-reference.html">
            
                <a href="../../../appendices/query-reference.html">
            
                    
                    E. Axon Server Query Language
            
                </a>
            

            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            Published with GitBook
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../.." >Reactor Gateways</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h1 id="reactive-gateways">Reactive Gateways</h1>
<p>The &quot;Reactive Gateways&quot; offer a reactive API wrapper around the command, query and event bus.
Most of the operations are similar to those from non-reactive gateways, simply replacing the <code>CompletableFuture</code> with either a <code>Mono</code> or <code>Flux</code>.
In some cases, the API is expended to ease use of common reactive patterns.</p>
<p> hint style=&quot;info&quot; 
Reactor doesn&apos;t allow <code>null</code> values in streams.
Any null value returned from the handler will be mapped to <a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Mono.html#empty" target="_blank">Mono#empty()</a>.
 endhint </p>
<blockquote>
<p><strong>Retrying operations</strong></p>
<p>All operations support Reactor&apos;s retry mechanism:</p>
<p><code>reactiveQueryGateway.query(query, ResponseType.class).retry(5);</code></p>
<p>This call will retry sending the query a maximum of five times when it fails.</p>
</blockquote>
<h2 id="configuration-in-spring-boot">Configuration in Spring Boot</h2>
<p>This extension can be added as a Spring Boot starter dependency to your project using group id <code>org.axonframework.extensions.reactor</code> and artifact id <code>axon-reactor-spring-boot-starter</code>.
The implementation of the extension can be found <a href="https://github.com/AxonFramework/extension-reactor" target="_blank">here</a>.</p>
<h2 id="reactor-command-gateway">Reactor Command Gateway</h2>
<p>This section describes the methods on the <code>ReactorCommandGateway</code>.</p>
<p><strong><code>send</code></strong> - Sends the given command once the caller subscribes to the command result. Returns immediately.</p>
<p>A common pattern is using the REST API to send a command. 
In this case it is recommend to for example use <a href="https://docs.spring.io/spring-framework/docs/5.0.0.BUILD-SNAPSHOT/spring-framework-reference/html/web-reactive.html" target="_blank">WebFlux</a>, and return the command result <code>Mono</code> directly to the controller:</p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SpringCommandController</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorCommandGateway reactiveCommandGateway; 

    <span class="hljs-meta">@PostMapping</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Mono&lt;CommandHandlerResponseBody&gt; <span class="hljs-title">sendCommand</span><span class="hljs-params">(@RequestBody CommandBody command)</span> </span>{
        <span class="hljs-keyword">return</span> reactiveCommandGateway.send(command);
    }
}
</code></pre>
<p><em>Sending a command from a Spring WebFlux Controller.</em></p>
<p> hint style=&quot;info&quot; 
If the command handling function returns type <code>void</code>, <code>Mono&lt;CommandHandlerResponseBody&gt;</code> should be replaced with <code>Mono&lt;Void&gt;</code>
 endhint </p>
<p>Another common pattern is &quot;send and forget&quot;:  </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CommandDispatcher</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorCommandGateway reactiveCommandGateway;

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">sendAndForget</span><span class="hljs-params">(MyCommand command)</span> </span>{
         reactiveCommandGateway.send(command)
                               .subscribe();
    }
}
</code></pre>
<p><em>Function that sends a command and returns immediately without waiting for the result.</em></p>
<p><strong><code>sendAll</code></strong> - This method uses the given <code>Publisher</code> of commands to dispatch incoming commands.</p>
<p> hint style=&quot;info&quot; 
This operation is available only in the Reactor extension. Use it to connect 3rd party streams that delivers commands.
 endhint </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CommandPublisher</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorCommandGateway reactiveCommandGateway;

    <span class="hljs-meta">@PostConstruct</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">startReceivingCommands</span><span class="hljs-params">(Flux&lt;CommandBody&gt; inputStream)</span> </span>{
        reactiveCommandGateway.sendAll(inputStream)
                              .subscribe();
    }
}
</code></pre>
<p><em>Connects an external input stream directly to the Reactor Command Gateway.</em></p>
<p> hint style=&quot;info&quot; 
The <code>sendAll</code> operation will keep sending commands until the input stream is canceled. 
 endhint </p>
<p> hint style=&quot;warn&quot; 
<code>send</code> and <code>sendAll</code> do not offer <em>any</em> backpressure, yet. 
The only backpressure mechanism in place is that commands will be sent sequentially; thus once the result of a previous command arrives.
The number of commands is prefetched from an incoming stream and stored in a buffer for sending (see <a href="https://projectreactor.io/docs/core/release/api/reactor/core/publisher/Flux.html#concatMap" target="_blank">Flux#concatMap</a>).
<strong>This slows down sending</strong>, but does not guarantee that the Subscriber will not be overwhelmed with commands if they are sent too fast.
 endhint </p>
<h2 id="reactor-query-gateway">Reactor Query Gateway</h2>
<p><strong><code>query</code></strong> - Sends the given <code>query</code>, expecting a response in the form of <code>responseType</code> from a single source.</p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SpringQueryController</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorQueryGateway reactiveQueryGateway;

    <span class="hljs-comment">// The query&apos;s Mono is returned to the Spring controller. Subscribe control is given to Spring Framework.</span>
    <span class="hljs-meta">@GetMapping</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Mono&lt;SomeResponseType&gt; <span class="hljs-title">findAll</span><span class="hljs-params">(FindAllQuery query, Class&lt;SomeResponseType&gt; responseType)</span> </span>{
        <span class="hljs-keyword">return</span> reactiveQueryGateway.query(query, responseType);
    }
}
</code></pre>
<p><em>Recommended way of using the Reactor query gateway within a Spring REST controller.</em></p>
<p><strong><code>scatterGather</code></strong> - Sends the given <code>query</code>, expecting a response in the form of <code>responseType</code> from several sources within a specified <code>duration</code>. </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SpringQueryController</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorQueryGateway reactiveQueryGateway;

    <span class="hljs-meta">@GetMapping</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> Flux&lt;SomeResponseType&gt; <span class="hljs-title">findMany</span><span class="hljs-params">(FindManyQuery query)</span> </span>{
        <span class="hljs-keyword">return</span> reactiveQueryGateway.scatterGather(query, SomeResponseType.class, Duration.ofSeconds(<span class="hljs-number">5</span>)).take(<span class="hljs-number">3</span>);
    }
}
</code></pre>
<p><em>Sends a given query that stops after receiving three results, or after 5 seconds.</em></p>
<h3 id="subscription-queries">Subscription queries</h3>
<p>Firstly, the Reactor API for subscription queries in Axon is not new. </p>
<p>However, we noticed several patterns which are often used, such as:</p>
<ul>
<li>Concatenating initial results with query updates in a single stream, or</li>
<li>skipping the initial result all together.</li>
</ul>
<p>As such, the Reactor Extension provides several methods to ease usage of these common patterns. </p>
<p><strong><code>subscriptionQuery</code></strong> - Sends the given <code>query</code>, returns the initial result and keeps streaming incremental updates until a subscriber unsubscribes from the <code>Flux</code>.</p>
<p>Note that this method should be used when the response type of the initial result and incremental update match.</p>
<pre><code class="lang-java">Flux&lt;ResultType&gt; resultFlux = reactiveQueryGateway.subscriptionQuery(<span class="hljs-string">&quot;criteriaQuery&quot;</span>, ResultType.class);
</code></pre>
<p>The above invocation through the <code>ReactorQueryGateway</code> is equivalent to: </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SubscriptionQuerySender</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorQueryGateway reactiveQueryGateway;

    <span class="hljs-function"><span class="hljs-keyword">public</span> Flux&lt;SomeResponseType&gt; <span class="hljs-title">sendSubscriptionQuery</span><span class="hljs-params">(SomeQuery query, Class&lt;SomeResponseType&gt; responseType)</span> </span>{
        <span class="hljs-keyword">return</span> reactiveQueryGateway.subscriptionQuery(query, responseType, responseType)
                                   .flatMapMany(result -&gt; result.initialResult()
                                                                .concatWith(result.updates())
                                                                .doFinally(signal -&gt; result.close()));
    }   
}
</code></pre>
<p><strong><code>subscriptionQueryMany</code></strong> - Sends the given <code>query</code>, returns the initial result and keeps streaming incremental updates until a subscriber unsubscribes from the <code>Flux</code>.</p>
<p>This operation should be used when the initial result contains multiple instances of the response type which needs to be flattened.
Additionally, the response type of the initial response and incremental updates need to match.</p>
<pre><code class="lang-java">Flux&lt;ResultType&gt; resultFlux = reactiveQueryGateway.subscriptionQueryMany(<span class="hljs-string">&quot;criteriaQuery&quot;</span>, ResultType.class);
</code></pre>
<p>The above invocation through the <code>ReactorQueryGateway</code> is equivalent to: </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SubscriptionQuerySender</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorQueryGateway reactiveQueryGateway;

    <span class="hljs-function"><span class="hljs-keyword">public</span> Flux&lt;SomeResponseType&gt; <span class="hljs-title">sendSubscriptionQuery</span><span class="hljs-params">(SomeQuery query, Class&lt;SomeResponseType&gt; responseType)</span> </span>{
        <span class="hljs-keyword">return</span> reactiveQueryGateway.subscriptionQuery(query,
                                                      ResponseTypes.multipleInstancesOf(responseType),
                                                      ResponseTypes.instanceOf(responseType))
                                   .flatMapMany(result -&gt; result.initialResult()
                                                                .flatMapMany(Flux::fromIterable)
                                                                .concatWith(result.updates())
                                                                .doFinally(signal -&gt; result.close()));
    }
}
</code></pre>
<p><strong><code>queryUpdates</code></strong> - Sends the given <code>query</code> and streams incremental updates until a subscriber unsubscribes from the <code>Flux</code>.</p>
<p>This method could be used when subscriber is only interested in updates.</p>
<pre><code class="lang-java">Flux&lt;ResultType&gt; updatesOnly = reactiveQueryGateway.queryUpdates(<span class="hljs-string">&quot;criteriaQuery&quot;</span>, ResultType.class);
</code></pre>
<p>The above invocation through the <code>ReactorQueryGateway</code> is equivalent to:  </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">SubscriptionQuerySender</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorQueryGateway reactiveQueryGateway;

    <span class="hljs-function"><span class="hljs-keyword">public</span> Flux&lt;SomeResponseType&gt; <span class="hljs-title">sendSubscriptionQuery</span><span class="hljs-params">(SomeQuery query, Class&lt;SomeResponseType&gt; responseType)</span> </span>{
        <span class="hljs-keyword">return</span> reactiveQueryGateway.subscriptionQuery(query, ResponseTypes.instanceOf(Void.class), responseType)
                                   .flatMapMany(result -&gt; result.updates()
                                                                .doFinally(signal -&gt; result.close()));
    }
}
</code></pre>
<p> hint style=&quot;info&quot; 
In the above shown methods, the subscription query is closed automatically after a subscriber has unsubscribed from the <code>Flux</code>. 
When using the regular <code>QueryGateway</code>, the subscription query needs to be closed manually however.
 endhint </p>
<h2 id="reactor-event-gateway">Reactor Event Gateway</h2>
<p>Reactive variation of the <code>EventGateway</code>. Provides support for reactive return types such as <code>Flux</code>.</p>
<p><strong><code>publish</code></strong> - Publishes the given <code>events</code> once the caller subscribes to the resulting <code>Flux</code>.</p>
<p>This method returns events that were published. 
Note that the returned events may be different from those the user has published, granted an <a href="#interceptors">interceptor</a> has been registered which modifies events.</p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">EventPublisher</span> </span>{

    <span class="hljs-keyword">private</span> <span class="hljs-keyword">final</span> ReactorEventGateway reactiveEventGateway;

    <span class="hljs-comment">// Register a dispatch interceptor to modify the event messages</span>
    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-title">EventPublisher</span><span class="hljs-params">()</span> </span>{
        reactiveEventGateway.registerDispatchInterceptor(
            eventMono -&gt; eventMono.map(event -&gt; GenericEventMessage.asEventMessage(<span class="hljs-string">&quot;intercepted&quot;</span> + event.getPayload()))
        );
    }

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">publishEvent</span><span class="hljs-params">()</span> </span>{
        Flux&lt;Object&gt; result = reactiveEventGateway.publish(<span class="hljs-string">&quot;event&quot;</span>);
    }   
}
</code></pre>
<p><em>Example of dispatcher modified events, returned to user as the result <code>Flux</code>.</em></p>
<h2 id="interceptors">Interceptors</h2>
<p>Axon provides a notion of <a href="../../../axon-framework/messaging-concepts/message-intercepting.html">interceptors</a>.
The Reactor gateways allow for similar interceptor logic, namely the <code>ReactorMessageDispatchInterceptor</code> and <code>ReactorResultHandlerInterceptor</code>.</p>
<p>These interceptors allow us to centrally define rules and filters that will be applied to a message stream.</p>
<p> hint style=&quot;info&quot; 
Interceptors will be applied in order they have been registered to the given component.
 endhint </p>
<h3 id="reactor-dispatch-interceptors">Reactor Dispatch Interceptors</h3>
<p>The <code>ReactorMessageDispatchInterceptor</code> should be used to centrally apply rules and validations for outgoing messages.
Note that a <code>ReactorMessageDispatchInterceptor</code> is an implementation of the default <code>MessageDispatchInterceptor</code> interface used throughout the framework.
The implementation of this interface is described as follows:</p>
<pre><code class="lang-java"><span class="hljs-meta">@FunctionalInterface</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">ReactorMessageDispatchInterceptor</span>&lt;<span class="hljs-title">M</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Message</span>&lt;?&gt;&gt; <span class="hljs-keyword">extends</span> <span class="hljs-title">MessageDispatchInterceptor</span>&lt;<span class="hljs-title">M</span>&gt; </span>{

    <span class="hljs-function">Mono&lt;M&gt; <span class="hljs-title">intercept</span><span class="hljs-params">(Mono&lt;M&gt; message)</span></span>;

    <span class="hljs-meta">@Override</span>
    <span class="hljs-function"><span class="hljs-keyword">default</span> BiFunction&lt;Integer, M, M&gt; <span class="hljs-title">handle</span><span class="hljs-params">(List&lt;? extends M&gt; messages)</span> </span>{
        <span class="hljs-keyword">return</span> (position, message) -&gt; intercept(Mono.just(message)).block();
    }
}
</code></pre>
<p>It thus defaults the <code>MessageDispatchInterceptor#handle(List&lt;? extends M&gt;</code> method to utilize the <code>ReactorMessageDispatchInterceptor#intercept(Mono&lt;M&gt;)</code> method.
As such, a <code>ReactorMessageDispatchInterceptor</code> could thus be configured on a plain Axon gateway too.
Here are a couple of examples how a message dispatch interceptor could be used:</p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ReactorConfiguration</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">registerDispatchInterceptor</span><span class="hljs-params">(ReactorCommandGateway reactiveGateway)</span> </span>{
        reactiveGateway.registerDispatchInterceptor(
            msgMono -&gt; msgMono.map(msg -&gt; msg.andMetaData(Collections.singletonMap(<span class="hljs-string">&quot;key1&quot;</span>, <span class="hljs-string">&quot;value1&quot;</span>)))
        );
    }
}
</code></pre>
<p><em>Dispatch interceptor that adds key-value pairs to the message&apos;s <code>MetaData</code>.</em></p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ReactorConfiguration</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">registerDispatchInterceptor</span><span class="hljs-params">(ReactorEventGateway reactiveGateway)</span> </span>{
        reactiveGateway.registerDispatchInterceptor(
            msgMono -&gt; msgMono.filterWhen(v -&gt; Mono.subscriberContext()
                              .filter(ctx-&gt; ctx.hasKey(<span class="hljs-string">&quot;security&quot;</span>))
                              .map(ctx-&gt;ctx.get(<span class="hljs-string">&quot;security&quot;</span>)))
        );
    }
}
</code></pre>
<p><em>Dispatch interceptor that discards the message, based on a security flag in the Reactor Context.</em></p>
<h3 id="reactor-result-handler-interceptors">Reactor Result Handler Interceptors</h3>
<p>The <code>ReactorResultHandlerInterceptor</code> should be used  to centrally apply rules and validations for incoming messages, a.k.a. results.
The implementation of this interface is described as follows:</p>
<pre><code class="lang-java"><span class="hljs-meta">@FunctionalInterface</span>
<span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">ReactorResultHandlerInterceptor</span>&lt;<span class="hljs-title">M</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">Message</span>&lt;?&gt;, <span class="hljs-title">R</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">ResultMessage</span>&lt;?&gt;&gt; </span>{

    <span class="hljs-function">Flux&lt;R&gt; <span class="hljs-title">intercept</span><span class="hljs-params">(M message, Flux&lt;R&gt; results)</span></span>;
}
</code></pre>
<p>The parameters are the <code>message</code> that has been sent, and a <code>Flux</code> of <code>results</code> from that message, which is going to be intercepted.
The <code>message</code> parameter can be useful if you want to apply a given result rule only for specific messages.
Here are a couple of examples how a message result interceptor could be used:</p>
<p> hint style=&quot;info&quot; 
This type of interceptor is available <em>only</em> in the Reactor Extension.
 endhint </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ReactorConfiguration</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">registerResultInterceptor</span><span class="hljs-params">(ReactorQueryGateway reactiveGateway)</span> </span>{
        reactiveGateway.registerResultHandlerInterceptor(
            (msg, results) -&gt; results.filter(r -&gt; !r.getPayload().equals(<span class="hljs-string">&quot;blockedPayload&quot;</span>))
        );
    }
}
</code></pre>
<p><em>Result interceptor which discards all results that have a payload matching <code>blockedPayload</code></em></p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ReactorConfiguration</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">registerResultInterceptor</span><span class="hljs-params">(ReactorQueryGateway reactiveGateway)</span> </span>{
        reactiveQueryGateway.registerResultHandlerInterceptor(
            (query, results) -&gt; results.flatMap(r -&gt; {
                <span class="hljs-keyword">if</span> (r.getPayload().equals(<span class="hljs-string">&quot;&quot;</span>)) {
                    <span class="hljs-keyword">return</span> Flux.&lt;ResultMessage&lt;?&gt;&gt;error(<span class="hljs-keyword">new</span> RuntimeException(<span class="hljs-string">&quot;no empty strings allowed&quot;</span>));
                } <span class="hljs-keyword">else</span> {
                    <span class="hljs-keyword">return</span> Flux.just(r);
                }
            })
        );
    }
}
</code></pre>
<p><em>Result interceptor which validates that the query result does not contain an empty <code>String</code>.</em> </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ReactorConfiguration</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">registerResultInterceptor</span><span class="hljs-params">(ReactorQueryGateway reactiveGateway)</span> </span>{
        reactiveQueryGateway.registerResultHandlerInterceptor(
            (q, results) -&gt; results.filter(it -&gt; !((<span class="hljs-keyword">boolean</span>) q.getQueryName().equals(<span class="hljs-string">&quot;myBlockedQuery&quot;</span>)))
        );
    }
}
</code></pre>
<p><em>Result interceptor which discards all results where the <code>queryName</code> matches <code>myBlockedQuery</code>.</em></p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ReactorConfiguration</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">registerResultInterceptor</span><span class="hljs-params">(ReactorCommandGateway reactiveGateway)</span> </span>{
        reactiveGateway.registerResultHandlerInterceptor(
            (msg,results) -&gt; results.timeout(Duration.ofSeconds(<span class="hljs-number">30</span>))
        );
    }
}
</code></pre>
<p><em>Result interceptor which limits the result waiting time to thirty seconds per message.</em> </p>
<pre><code class="lang-java"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">ReactorConfiguration</span> </span>{

    <span class="hljs-function"><span class="hljs-keyword">public</span> <span class="hljs-keyword">void</span> <span class="hljs-title">registerResultInterceptor</span><span class="hljs-params">(ReactorCommandGateway reactiveGateway)</span> </span>{
        reactiveGateway.registerResultHandlerInterceptor(
            (msg,results) -&gt; results.log().take(<span class="hljs-number">5</span>)
        );
    }
}
</code></pre>
<p><em>Result interceptor which limits the number of results to five entries, and logs all results.</em></p>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="../reactor.html" class="navigation navigation-prev " aria-label="Previous page: Reactor">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../../spring-cloud.html" class="navigation navigation-next " aria-label="Next page: Spring Cloud">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Reactor Gateways","level":"5.6.1","depth":2,"next":{"title":"Spring Cloud","level":"5.7","depth":1,"path":"extensions/spring-cloud.md","ref":"extensions/spring-cloud.md","articles":[]},"previous":{"title":"Reactor","level":"5.6","depth":1,"path":"extensions/reactor/reactor.md","ref":"extensions/reactor/reactor.md","articles":[{"title":"Reactor Gateways","level":"5.6.1","depth":2,"path":"extensions/reactor/reactive-gateways/reactive-gateways.md","ref":"extensions/reactor/reactive-gateways/reactive-gateways.md","articles":[]}]},"dir":"ltr"},"config":{"gitbook":"*","theme":"default","variables":{},"plugins":[],"pluginsConfig":{"highlight":{},"search":{},"lunr":{"maxIndexSize":1000000,"ignoreSpecialCharacters":false},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"}},"file":{"path":"extensions/reactor/reactive-gateways/reactive-gateways.md","mtime":"2021-09-13T08:33:05.968Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-09-13T08:33:36.904Z"},"basePath":"../../..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../../../gitbook/gitbook.js"></script>
    <script src="../../../gitbook/theme.js"></script>
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search-engine.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-search/search.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/lunr.min.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-lunr/search-lunr.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-sharing/buttons.js"></script>
        
    
        
        <script src="../../../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    

    </body>
</html>

